package org.jz.gae.redbook.spb.client.slate.menu;

import org.jz.gae.redbook.spb.client.slate.district.DistrictSlate;
import org.jz.gae.redbook.spb.client.slate.family.FamilySlate;
import org.jz.gae.redbook.spb.client.slate.location.LocationSlate;
import org.jz.gae.redbook.spb.client.slate.species.SpeciesSlate;
import org.jz.gae.redbook.spb.client.toolkit.Slate;

import com.google.gwt.event.dom.client.ClickEvent;
import com.google.gwt.event.dom.client.ClickHandler;
import com.google.gwt.user.client.ui.Button;
import com.google.gwt.user.client.ui.Composite;
import com.google.gwt.user.client.ui.SimplePanel;
import com.google.gwt.user.client.ui.VerticalPanel;

public class MenuPlate extends Composite
{
	private VerticalPanel rootPanel = new VerticalPanel();
	private Slate slate;
	
	public MenuPlate() 
	{
		SimplePanel contentTableDecorator = new SimplePanel();
	    initWidget(contentTableDecorator);
	    contentTableDecorator.setWidth("100%");
	    initInterface();
	    contentTableDecorator.add(rootPanel);
	}

	private void initInterface()
	{
		{
			Button familyListButton = new Button("Семейства");
			familyListButton.setWidth("100%");
			rootPanel.add(familyListButton);
			familyListButton.addClickHandler(new ClickHandler()
			{
				@Override
				public void onClick(ClickEvent event)
				{
					openFamilyListSlate();
				}
			});
		}
		{
			Button districtListButton = new Button("Районы");
			districtListButton.setWidth("100%");
			rootPanel.add(districtListButton);
			districtListButton.addClickHandler(new ClickHandler()
			{
				@Override
				public void onClick(ClickEvent event)
				{
					openDistrictListSlate();
				}
			});
		}
		{
			Button speciesListButton = new Button("Виды");
			speciesListButton.setWidth("100%");
			rootPanel.add(speciesListButton);
			speciesListButton.addClickHandler(new ClickHandler()
			{
				@Override
				public void onClick(ClickEvent event)
				{
					openSpeciesListSlate();
				}
			});
		}
		{
			Button locationListButton = new Button("Местонахождения");
			locationListButton.setWidth("100%");
			rootPanel.add(locationListButton);
			locationListButton.addClickHandler(new ClickHandler()
			{
				@Override
				public void onClick(ClickEvent event)
				{
					openLocationListSlate();
				}
			});
		}
		
	}
	
	public void initialize(
			Slate _Slate)
	{
		slate = _Slate;
	}
	
	private void openFamilyListSlate()
	{
		slate.getContainerAgent().openSlate(new FamilySlate());
	}
	
	private void openDistrictListSlate()
	{
		slate.getContainerAgent().openSlate(new DistrictSlate());
	}

	private void openSpeciesListSlate()
	{
		slate.getContainerAgent().openSlate(new SpeciesSlate());
	}

	private void openLocationListSlate()
	{
		slate.getContainerAgent().openSlate(new LocationSlate());
	}
}
